﻿/*
 * This software is the confidential and proprietary
 * information of NetBay
 * Such confidential information should not be disclosed
 * NetBay copyright(c) 2010
 */

#region Using
using System;
using System.Collections.Generic;
using System.ServiceModel.DomainServices.Server;
using NetBay.Core.BusinessEntities;
using NetBay.Core.Log;
using Rio.Framework.Business.Repository;
using Rio.Doc.Business.Repository;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.ServiceModel.DomainServices.Hosting;
using Rio.Manager.Business.Repository;
using System.DirectoryServices;
using System.Collections.ObjectModel;
using NetBay.Core.Tools;
using System.Transactions;
#endregion

namespace Rio.Applications.Web.Services
{
    /// <summary>
    /// Class to handle Business entities in a RIA services
    /// </summary>
    public partial class BusinessEntitiesDomainService : DomainService
    {
        [Query]
        public IEnumerable<Group> GetAllGroup()
        {
            //Variable initialization.
            List<Group> l_oRet = new List<Group>();

            //Log.
            NetBay.Core.Log.LogManager.Instance().LogDebug("GroupDS.GetAllGroup (No parameters)...");

            try
            {
                l_oRet = GeneralGroupRepository.GetAllGroup();
            }
            catch (Exception ex)
            {
                //Error log.
                NetBay.Core.Log.LogManager.Instance().LogError("GroupDS.GetAllGroup Exception [" + ex.Message + "]");
            }
            return l_oRet;
        }

        [Query(HasSideEffects = true)]
        public IEnumerable<Group> GetAllGroupRioByOrganization(long p_lOrganizationId)
        {
            //Variable initialization.
            var l_oRetGroup = new List<Group>();

            //Log.
            NetBay.Core.Log.LogManager.Instance().LogDebug("GroupDS.GetAllGroupRioByOrganization (p_lOrganizationId <" + p_lOrganizationId + ">)...");

            try
            {
                l_oRetGroup = GeneralGroupRepository.GetAllGroupRioByOrganization(p_lOrganizationId);
            }
            catch (Exception ex)
            {
                //Error log.
                NetBay.Core.Log.LogManager.Instance().LogError("GroupDS.GetAllGroupRioByOrganization Exception [" + ex.Message + "]");
            }

            //Return value.
            return l_oRetGroup;
        }
    }
}